Conditions | 1 |
Paths | 1 |
Total Lines | 42 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /** |
||
5 | jQuery( document ).ready( function () { |
||
6 | /** |
||
7 | * Normal select2. |
||
8 | */ |
||
9 | jQuery( '.select2-taxonomy' ).select2( { |
||
10 | width: '300px' |
||
11 | } ); |
||
12 | |||
13 | /** |
||
14 | * Enable AJAX for Taxonomy Select2. |
||
15 | */ |
||
16 | jQuery( '.select2-taxonomy-ajax' ).select2( { |
||
17 | ajax: { |
||
18 | url: ajaxurl, |
||
19 | dataType: 'json', |
||
20 | delay: 250, |
||
21 | data: function ( params ) { |
||
22 | return { |
||
23 | q: params.term, |
||
24 | taxonomy: jQuery( this ).attr( 'data-taxonomy' ), |
||
25 | action: 'bd_load_taxonomy_term' |
||
26 | }; |
||
27 | }, |
||
28 | processResults: function ( data ) { |
||
29 | var options = []; |
||
30 | |||
31 | if ( data ) { |
||
32 | jQuery.each( data, function ( index, dataPair ) { |
||
33 | options.push( { id: dataPair[ 0 ], text: dataPair[ 1 ] } ); |
||
34 | } ); |
||
35 | } |
||
36 | |||
37 | return { |
||
38 | results: options |
||
39 | }; |
||
40 | }, |
||
41 | cache: true |
||
42 | }, |
||
43 | minimumInputLength: 2, // the minimum of symbols to input before perform a search |
||
44 | width: '300px' |
||
45 | } ); |
||
46 | } ); |
||
47 |